__author__ = "Chengye zhao (chengyezhao@gmail.com)"

from google.appengine.ext import db
from google.appengine.api import urlfetch
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import logging
from search import getSearchResult
from product import getProductListXml 

class ProcessSearchJob(webapp.RequestHandler):
	def get(self):
		query = self.request.get("query")
		if not query:
			return
		words = query.split(',')
		result = getSearchResult(words)
		self.response.out.write(getProductListXml(result))

application = webapp.WSGIApplication(
	[('/search', ProcessSearchJob)],
	debug=True)

def main():
	run_wsgi_app(application)

if __name__ == "__main__":
	main()
